Skip to content

Conversation

kligarski
Copy link
Contributor

@kligarski kligarski commented Oct 8, 2025

Description

Limits changing tab bar item instances (PR introducing this) to only necessary cases (changing systemItem). Unnecessary updates caused a bug when changing e.g. only badgeValue.

before after
before.mov
after.mov

Fixes #3273.

Changes

  • separate creating new UITabBarItem instance and updating tab bar item related props
  • create new UITabBarItem instance only on systemItem change
  • restore default system item's icon by extracting it from new UITabBarSystemItem instance instead of changing the entire UITabBarItem

Test code and steps to reproduce

Run TestBottomTabs. Change badgeValue on selected tab. You can also check test cases from #3164.

Checklist

  • Included code example that can be used to test this change
  • Ensured that CI passes

Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the direction on this PR.
I've just got remarks regarding naming. Let's update that & proceed.

#if !RCT_NEW_ARCH_ENABLED
BOOL _tabItemNeedsAppearanceUpdate;
BOOL _tabScreenOrientationNeedsUpdate;
BOOL _tabBarItemNeedsBaseChange;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When reading the code for the first time the base part made no sense to me. What we want to signal here is that the tab bar item needs to be recreated & requires allocating completely new instance. What about naming it _tabBarItemNeedsRecreation then? What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also rename the changeTabBarItem appropriately. createTabBarItem?

Comment on lines +58 to +71
} else if (screenView.systemItem != RNSBottomTabsScreenSystemItemNone) {
// Restore default system item icon
UITabBarSystemItem systemItem =
rnscreens::conversion::RNSBottomTabsScreenSystemItemToUITabBarSystemItem(screenView.systemItem);
tabBarItem.image = [[UITabBarItem alloc] initWithTabBarSystemItem:systemItem tag:0].image;
}

if (screenView.selectedIconSfSymbolName != nil) {
tabBarItem.selectedImage = [UIImage systemImageNamed:screenView.selectedIconSfSymbolName];
} else if (screenView.systemItem != RNSBottomTabsScreenSystemItemNone) {
// Restore default system item icon
UITabBarSystemItem systemItem =
rnscreens::conversion::RNSBottomTabsScreenSystemItemToUITabBarSystemItem(screenView.systemItem);
tabBarItem.selectedImage = [[UITabBarItem alloc] initWithTabBarSystemItem:systemItem tag:0].selectedImage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tabs][iOS 26] Setting badge value on active tab, causes a glitch

4 participants